<div class="vj_box_300">
    <div class="title_300"><span>Lưu Bút <strong></strong></span></div>
    <div class="content_300" id="luubut_ajax">
        <div class="vj_textare_com">
            <textarea rows="" cols="" name="guest_book_content" id="txtContent"></textarea>
        </div>
        <div class="fo_300">
            <input type="hidden" id="hdOwner" value="<?php echo $owner_id ?>">
            <label><a href="#" id="btnSend">Gửi tin</a></label>
        </div>
        <div id="luubut_detail" class="vj_luubut_detail">
            <ul>
                <?php if ($total > 0) { ?>
                    <?php $this->widget('zii.widgets.CListView', array(
                        'id' => 'guestBook-list',
                        'enableSorting' => false,
                        'dataProvider' => $model,
                        'itemView' => '_viewSmallGuestBook',
                    )); ?>
                <?php } ?>
            </ul>
        </div>
    </div>
</div>
<script type="text/javascript">
    var proccessing = false;
    var $host = "<?php echo TreTodayUrl::home()?>";
    $(document).ready(function () {

        $("#btnSend").click(function () {
            if (proccessing)return;

            var $content = $("#txtContent").val();
            if ($content.trim() == '') {
                return;
            }
            var $data = {'content': $("#txtContent").val(), 'owner_id': $('#hdOwner').val()};
            $.ajax({
                'type': 'POST',
                'url': $host + '/ajax/sendGuestBook',
                'data': $data,
                'success': function (data) {
                    proccessing = false;
                    if (data['message']) {
                        alert(data['message']);
                    } else {
                        window.location.reload();
                    }

                }
            });
        });
    });
</script>

